package com.ruoyi.web.controller.webs.ky450;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.domain.LsKyJssyb;
import com.ruoyi.web.exception.CommonEnum;
import com.ruoyi.web.service.LsKyJssybService;
import com.ruoyi.web.vo.SearchVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "翻译工具相关")
@RequestMapping(value = "/webs/translate", method = RequestMethod.POST)
@RestController
public class NetworkTranslateController {

    @Autowired
    private LsKyJssybService lsKyJssybService;


    @ApiOperation(value = "翻译工具-自动识别语言")
    @RequestMapping(value = "identifyTranslate",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyword", value = "关键词"),
    })
    public AjaxResult identifyTranslate(String keyword) {
        if (StringUtils.isEmpty(keyword))
            return AjaxResult.error(CommonEnum.MISS_PARAM.getResultMsg());
        return lsKyJssybService.identifyTranslate(keyword);
    }

    @ApiOperation(value = "翻译工具")
    @RequestMapping(value = "translateUtils",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyword", value = "关键词"),
            @ApiImplicitParam(name = "source", value = "语言(从) en 英文 ge 德语 ja 日语 ko 韩语 zh 中文"),
            @ApiImplicitParam(name = "target", value = "语言(到) en 英文 ge 德语 ja 日语 ko 韩语 zh 中文"),
    })
    public AjaxResult translateUtils(String keyword, String source, String target) {
        if (StringUtils.isEmpty(keyword) || StringUtils.isEmpty(source) || StringUtils.isEmpty(target))
            return AjaxResult.error(CommonEnum.MISS_PARAM.getResultMsg());
        return lsKyJssybService.translateUtils(keyword, source, target);
    }

    @RequestMapping("queryList")
    @ApiOperation(value = "分页检索翻译工具-军事术语-By：关键词、页码")
    public AjaxResult queryList(SearchVO svo) {
        if (svo.getPageNum() == null) svo.setPageNum(1);
        if (svo.getPageSize() == null) svo.setPageSize(10);
        return lsKyJssybService.queryList(svo);
    }

    @ApiOperation(value = "添加翻译工具-军事术语")
    @RequestMapping(value = "insertData",method = RequestMethod.POST)
    public AjaxResult insertData(@RequestBody LsKyJssyb translate) {
        if (translate == null || StringUtils.isEmpty(translate.getMc()) || StringUtils.isEmpty(translate.getJg()))
            return AjaxResult.error(CommonEnum.MISS_PARAM.getResultMsg());
        return lsKyJssybService.insert(translate);
    }

    @ApiOperation(value = "修改翻译工具-军事术语")
    @RequestMapping(value = "updateData",method = RequestMethod.POST)
    public AjaxResult updateData(@RequestBody LsKyJssyb translate) {
        if (translate == null || translate.getId() == null || StringUtils.isEmpty(translate.getMc()) || StringUtils.isEmpty(translate.getJg()))
            return AjaxResult.error(CommonEnum.MISS_PARAM.getResultMsg());
        return lsKyJssybService.update(translate);
    }

    @ApiOperation(value = "批量删除翻译工具-军事术语")
    @RequestMapping(value = "batchDelete",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "数据内码，多个用英文逗号隔开"),
    })
    public AjaxResult batchDelete(String ids) {
        if (StringUtils.isEmpty(ids))
            return AjaxResult.error(CommonEnum.MISS_PARAM.getResultMsg());
        return lsKyJssybService.batchDelete(ids);
    }

}
